package ucm.module;
import air_cp5620.dao.DAO;
import javax.swing.JOptionPane;
import java.sql.*;

public class UC_DelAirM {
    private String id = null;
    private DAO dbCon = null;

    public UC_DelAirM(String id) {
        this.id = id;
        dbCon = new DAO();
    }


    public boolean delete()
    {
        String sql = null;
        Connection con = dbCon.getConnection();
        if (con == null) {
            JOptionPane.showMessageDialog(null, "Don't get connection!");
            return false;
        }
        try {
            Statement stmt = con.createStatement(ResultSet.CONCUR_UPDATABLE, ResultSet.CONCUR_UPDATABLE);
            sql = "update tbl_air_info set isdelete='1' where id='" + id + "'";
            stmt.executeUpdate(sql);
            JOptionPane.showMessageDialog(null, "Deleted air info successfully");
            return true;

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Deleted air info error!");
            e.printStackTrace();
            return false;
        }
    }
}
